package com.authine.cloudpivot.common.extension.defaultextension;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.alibaba.fastjson.JSON;
import com.authine.cloudpivot.common.extension.client.dto.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 文组织同步获取数据源服务扩展点默认扩展实现
 * <p>
 * 请勿修改任何类和方法的定义
 * <p>
 * 只需要在方法内部编写业务逻辑
 */
@Api(tags = "同步获取数据源服务扩展点")
@Slf4j
@RestController
@RequestMapping("/orgsync/v1")
public class OrgDataSourceExtensionController {

    @ApiOperation(value = "获取jsapi ticket")
    @ApiImplicitParam(name = "corpId", value = "第三方企业id")
    @GetMapping("/get_jsapi_ticket")
    public SingleResponse<String> getJsapiTicket(@RequestParam(name = "corpId") String corpId) {
        log.info("二开get js api ticket...{}", corpId);
        // TODO 编写二开代码
        return SingleResponse.of(null);
    }

    @ApiOperation(value = "获取第三方授权访问令牌")
    @ApiImplicitParam(name = "corpId", value = "第三方企业id")
    @GetMapping("/get_access_token")
    public SingleResponse<String> getAccessToken(@RequestParam(name = "corpId") String corpId) {
        log.info("二开获取访问令牌...{}", corpId);
        // TODO 编写二开代码
        return SingleResponse.of(null);
    }

    @ApiOperation(value = "标签列表")
    @ApiImplicitParam(name = "corpId", value = "第三方企业id")
    @GetMapping("/list_label")
    public MultiResponse<LabelDTO> listLabel(@RequestParam(name = "corpId") String corpId) {
        log.info("二开查询标签列表...{}", corpId);
        // TODO 编写二开代码
        return MultiResponse.ofWithoutTotal(null);
    }

    @ApiOperation(value = "部门列表")
    @ApiImplicitParam(name = "corpId", value = "第三方企业id")
    @GetMapping("/list_department")
    public MultiResponse<DepartmentDTO> listDepartment(@RequestParam(name = "corpId") String corpId) {
        log.info("二开查询部门列表...{}", corpId);
        // TODO 编写二开代码
        return MultiResponse.ofWithoutTotal(null);
    }

    @ApiOperation(value = "查询单个部门")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "corpId", value = "第三方企业id"),
            @ApiImplicitParam(name = "departmentId", value = "部门id")
    })
    @GetMapping("/get_department")
    public SingleResponse<DepartmentDTO> getDepartment(@RequestParam(name = "corpId") String corpId, @RequestParam(name = "deptId") String departmentId) {
        log.info("二开查询部门...{}, {}", corpId, departmentId);
        // TODO 编写二开代码
        return SingleResponse.of(null);
    }

    @ApiOperation(value = "查询单个用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "corpId", value = "第三方企业id"),
            @ApiImplicitParam(name = "id", value = "用户id")
    })
    @GetMapping("/get_user")
    public SingleResponse<UserDTO> getUser(@RequestParam(name = "corpId") String corpId, @RequestParam(name = "id") String id) {
        log.info("二开查询用户...{}, {}", corpId, id);
        // TODO 编写二开代码
        return SingleResponse.of(null);
    }

    @ApiOperation(value = "查询部门下的用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "corpId", value = "第三方企业id"),
            @ApiImplicitParam(name = "departmentId", value = "部门id")
    })
    @GetMapping("/list_user_by_department_id")
    public MultiResponse<UserDTO> listUsersByDepartmentId(@RequestParam(name = "corpId") String corpId, @RequestParam(name = "departmentId") String departmentId) {
        log.info("二开根据部门查询用户...{}, {}", corpId, departmentId);
        // TODO 编写二开代码
        return MultiResponse.ofWithoutTotal(null);
    }

    @ApiOperation(value = "查询标签下的用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "corpId", value = "第三方企业id"),
            @ApiImplicitParam(name = "labelId", value = "标签id")
    })
    @GetMapping("/list_user_by_label_id")
    public MultiResponse<UserDTO> listUsersByLabelId(@RequestParam(name = "corpId") String corpId, @RequestParam(name = "labelId") String labelId) {
        log.info("二开根据标签查询用户...{}, {}", corpId, labelId);
        // TODO 编写二开代码
        return MultiResponse.ofWithoutTotal(null);
    }

    @ApiOperation(value = "查询单个标签")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "corpId", value = "第三方企业id"),
            @ApiImplicitParam(name = "labelId", value = "标签id")
    })
    @GetMapping("/get_label_by_id")
    public SingleResponse<LabelDTO> getLabelById(@RequestParam(name = "corpId") String corpId, @RequestParam(name = "labelId") String labelId) {
        log.info("二开查询标签...{}, {}", corpId, labelId);
        // TODO 编写二开代码
        return SingleResponse.of(null);
    }

    @ApiOperation(value = "标签组列表")
    @ApiImplicitParam(name = "corpId", value = "第三方企业id")
    @GetMapping("/list_label_group")
    public MultiResponse<LabelGroupDTO> listLabelGroup(@RequestParam(name = "corpId") String corpId) {
        log.info("二开查询标签组列表...{}", corpId);
        // TODO 编写二开代码
        return MultiResponse.ofWithoutTotal(null);
    }

    @ApiOperation(value = "增量同步")
    @ApiImplicitParam(name = "params", value = "增量同步入参")
    @PostMapping("/increment_sync")
    public SingleResponse<OrgIncrementDTO> incrementSync(@RequestBody Object params) {
        log.info("二开增量同步...{}", JSON.toJSONString(params));
        // TODO 编写二开代码
        return SingleResponse.of(null);
    }

}
